//
//  ChooseTableViewCell.m
//  SafeFoodManagerDemo
//
//  Created by bob on 2017/10/23.
//  Copyright © 2017年 bob. All rights reserved.
//

#import "ChooseTableViewCell.h"

@implementation ChooseTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(void)setWmodel:(ChooseListData *)Wmodel
{
    _Wmodel=Wmodel;
    
    if ([Wmodel.fieldName isEqualToString:@"areaId1"]||[Wmodel.fieldName isEqualToString:@"areaId2"]||[Wmodel.fieldName isEqualToString:@"areaId3"]||[Wmodel.fieldName isEqualToString:@"areaId4"]||[Wmodel.fieldName isEqualToString:@"type"]||[Wmodel.fieldName isEqualToString:@"confirmState"]||[Wmodel.fieldName isEqualToString:@"rectifyState"]||[Wmodel.fieldName isEqualToString:@"subjectId"]||[Wmodel.fieldName isEqualToString:@"groupId"]) {
        
        if (Wmodel.name.length==0) {
            
            Wmodel.name=@" ";
        }
        
         self.ContentLabel.text=Wmodel.name;
        
        if ([Wmodel.fieldName isEqualToString:@"areaId1"]) {
            
            self.TipLabel.text=@"省";
            
           
        }else if ([Wmodel.fieldName isEqualToString:@"areaId2"]) {
            
            self.TipLabel.text=@"市";
          
        }else if ([Wmodel.fieldName isEqualToString:@"areaId3"]) {
            
            self.TipLabel.text=@"区";
            
        }else if ([Wmodel.fieldName isEqualToString:@"areaId4"]) {
            
            self.TipLabel.text=@"街道";
            
        }else if ([Wmodel.fieldName isEqualToString:@"type"]) {
            
            self.TipLabel.text=@"类型";
            
        }else if ([Wmodel.fieldName isEqualToString:@"confirmState"]) {
            
            self.TipLabel.text=@"确认状态";
            
        }else if ([Wmodel.fieldName isEqualToString:@"rectifyState"]) {
            
            self.TipLabel.text=@"整改状态";
            
        }else if ([Wmodel.fieldName isEqualToString:@"subjectId"])
        {
         
            self.TipLabel.text=@"检查表";
            
        }else if ([Wmodel.fieldName isEqualToString:@"groupId"])
        {
            if(Wmodel.isCheckGroup)
            {
                self.TipLabel.text=@"检查员分组";
            }else
                self.TipLabel.text=@"商户分组";
            
        }
   
    }else if ([Wmodel.fieldName isEqualToString:@"isAnswer"] || [Wmodel.fieldName isEqualToString:@"isMark"])//是否交卷、封卷
    {
        self.TipLabel.text=Wmodel.name;
        self.ContentLabel.text=@" ";
        for(int i=0;i<Wmodel.items.count;i++)
        {
            ChooseListItems *item = Wmodel.items[i];
            if([item.value isEqualToString:Wmodel.value])
            {
                self.ContentLabel.text=item.name;
            }
        }
    }else if ([Wmodel.productType isEqualToString:@"商品分类"])
    {
        self.TipLabel.text=@"分类";
        self.ContentLabel.text=[Wmodel.name isEqualToString:@"分类"]?@"全部":Wmodel.name;
    }
    else if ([Wmodel.fieldName isEqualToString:@"catId"])//添加剂分类
    {
        self.TipLabel.text=@"分类";
        self.ContentLabel.text=[Wmodel.name isEqualToString:@"分类"]?@"全部":Wmodel.name;
    }else if ([Wmodel.fieldName isEqualToString:@"examId"])//考题列表
    {
        self.TipLabel.text=@"考题";
        self.ContentLabel.text=[Wmodel.name isEqualToString:@"考题"]?@"全部":Wmodel.name;
    }
    else{
    
        self.TipLabel.text=Wmodel.name;
        
        if (Wmodel.value.length==0) {
            
            self.ContentLabel.text=@" ";
            
        }else{
            
            self.ContentLabel.text=Wmodel.value;
        }
    }
}

-(void)setCmodel:(ChooseListData *)Cmodel
{
    _Cmodel=Cmodel;
    
    self.TipLabel.text=Cmodel.name;
    
    NSString *showStr=@" ";
    
    
    for (ChooseListItems *item in Cmodel.items) {
        
        if (item.selected) {
            
            Cmodel.value=item.value;
            
            break;
        }
        
    }
    
    for (ChooseListItems *item in Cmodel.items) {
        
        if ([Cmodel.value isEqualToString:item.value]) {
            
            showStr=item.name;
            
            break;
        }
  
    }
 
    self.ContentLabel.text=showStr;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
